/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Interface.Despesa.Geral;

import Interface.Despesa.Apresentador.*;
import static Interface.Global.aux;
import Modelo.Despesa.Despesa;
import Modelo.Edicao.Edicao;
import Modelo.Evento.Evento;
import Util.ExcecaoInstanciaNaoEncontrada;
import Util.ExcecaoSaldoInsuficiente;
import java.awt.Component;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 *
 * @author ana.siena
 */
public class AtualizarDespesa extends javax.swing.JFrame {

    private long codDespesa;
    private long codEvento;
    private int numeroEdicao; 
    private Despesa despesa;
    private Calendar dataDespesa;
    private float valorDespesa;
    private String descricaoDespesa;
    private String tipoDespesa;
    private long codEven;
        
    public AtualizarDespesa() {
        initComponents();
        init();
    }
    
    private void init(){
	setVisible(true);
        setTitle("Atualizar Despesas");
        setLocationRelativeTo(null);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        //Preenche combobox do evento
        ArrayList <Evento> vetorCodEvento = new ArrayList <Evento>();
        vetorCodEvento = (ArrayList<Evento>) aux.buscarTodosEventos();
        
        for(int i=0; i<vetorCodEvento.size();i++)
        {
            codEventoCombo.addItem(vetorCodEvento.get(i).getCodEvento());
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        codEventoCombo = new javax.swing.JComboBox();
        nroEdicaoCombo = new javax.swing.JComboBox();
        codDespesaCombo = new javax.swing.JComboBox();
        jPanel2 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        dataText = new javax.swing.JTextField();
        valor = new javax.swing.JTextField();
        tipoDesp = new javax.swing.JTextField();
        descricao = new javax.swing.JTextField();
        botaoAlterar = new javax.swing.JButton();
        botaoConsultar = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        data1 = new javax.swing.JTextField();
        valor1 = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        tipoDesp1 = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        descricao1 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        botaoRetornar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Dados para busca"));

        jLabel2.setText("Codigo do evento:");

        jLabel3.setText("Nro da Edicao:");

        jLabel4.setText("Codigo da Despesa:");

        codEventoCombo.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                codEventoComboActionPerformed(evt);
            }
        });

        nroEdicaoCombo.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                nroEdicaoComboActionPerformed(evt);
            }
        });

        codDespesaCombo.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                codDespesaComboActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4))
                .addGap(34, 34, 34)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(codEventoCombo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(nroEdicaoCombo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(codDespesaCombo, 0, 122, Short.MAX_VALUE))
                .addContainerGap(126, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(codEventoCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(nroEdicaoCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(codDespesaCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Dados sobre a despesa"));

        jLabel5.setText("Data:");

        jLabel6.setText("Valor:");

        jLabel7.setText("Tipo de despesa:");

        jLabel9.setText("Descricao:");

        dataText.setEnabled(false);
        dataText.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                dataTextActionPerformed(evt);
            }
        });

        valor.setEnabled(false);

        tipoDesp.setEnabled(false);

        descricao.setEnabled(false);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6)
                    .addComponent(jLabel7)
                    .addComponent(jLabel9))
                .addGap(48, 48, 48)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(dataText, javax.swing.GroupLayout.DEFAULT_SIZE, 123, Short.MAX_VALUE)
                            .addComponent(valor)
                            .addComponent(tipoDesp))
                        .addGap(0, 115, Short.MAX_VALUE))
                    .addComponent(descricao))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(dataText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(valor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(tipoDesp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(descricao, javax.swing.GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE))
                .addGap(35, 35, 35))
        );

        botaoAlterar.setText("Alterar");
        botaoAlterar.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoAlterarActionPerformed(evt);
            }
        });

        botaoConsultar.setText("Consultar");
        botaoConsultar.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoConsultarActionPerformed(evt);
            }
        });

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Dados a serem atualizados"));

        jLabel10.setText("Data:");

        jLabel11.setText("Valor:");

        data1.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                data1ActionPerformed(evt);
            }
        });

        valor1.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                valor1ActionPerformed(evt);
            }
        });

        jLabel12.setText("Tipo de despesa:");

        tipoDesp1.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                tipoDesp1ActionPerformed(evt);
            }
        });

        jLabel14.setText("Descricao:");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addComponent(jLabel11)
                    .addComponent(jLabel12)
                    .addComponent(jLabel14))
                .addGap(48, 48, 48)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(data1, javax.swing.GroupLayout.DEFAULT_SIZE, 123, Short.MAX_VALUE)
                            .addComponent(valor1)
                            .addComponent(tipoDesp1))
                        .addContainerGap(125, Short.MAX_VALUE))
                    .addComponent(descricao1)))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(data1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(valor1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(tipoDesp1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel14)
                        .addGap(0, 30, Short.MAX_VALUE))
                    .addComponent(descricao1))
                .addContainerGap())
        );

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel1.setText("Atualizar uma Despesa");

        botaoRetornar.setText("Retornar");
        botaoRetornar.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoRetornarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(botaoRetornar)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(botaoConsultar)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(botaoAlterar))
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(134, 134, 134)
                        .addComponent(jLabel1)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(34, 34, 34)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botaoAlterar)
                    .addComponent(botaoConsultar)
                    .addComponent(botaoRetornar))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botaoRetornarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoRetornarActionPerformed
        new MenuDespesaApresentador().setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_botaoRetornarActionPerformed

    private void botaoConsultarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoConsultarActionPerformed
        this.numeroEdicao = Integer.parseInt((String) nroEdicaoCombo.getSelectedItem());
        this.codDespesa = Long.parseLong((String) codDespesaCombo.getSelectedItem());
        this.codEvento = Long.parseLong((String) codEventoCombo.getSelectedItem());
        
        try {                  
            this.despesa = aux.buscaDespesa(codEvento,numeroEdicao, (int) codDespesa);
        } catch (ExcecaoInstanciaNaoEncontrada ex) {
            Logger.getLogger(AtualizarDespesa.class.getName()).log(Level.SEVERE, null, ex);
            Component frame = null;
            JOptionPane.showMessageDialog(frame,ex.getMessage());
        }
        
        DateFormat df = new SimpleDateFormat("MM/dd/yyyy");       
        String data = df.format(despesa.getDataDespesa());
        dataText.setText(data);
        valor.setText(Float.toString(despesa.getValorDespesa()));
        tipoDesp.setText(despesa.getTipoDespesa());
        descricao.setText(despesa.getDescricaoDespesa());
        
        this.data1.setText(data);
        this.valor1.setText(Float.toString(despesa.getValorDespesa()));
        this.tipoDesp1.setText(despesa.getTipoDespesa());
        this.descricao1.setText(despesa.getDescricaoDespesa());
        
    }//GEN-LAST:event_botaoConsultarActionPerformed

    private void data1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_data1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_data1ActionPerformed

    private void valor1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_valor1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_valor1ActionPerformed

    private void tipoDesp1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tipoDesp1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tipoDesp1ActionPerformed

    private void dataTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dataTextActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_dataTextActionPerformed

    private void codEventoComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_codEventoComboActionPerformed
        codEven = Long.parseLong(""+ codEventoCombo.getSelectedItem());
               
        if(codEven == 0){
            System.out.println("Não tem nenhum evento selecionado");
        }
        else{
            //Preenche combobox do edicao
            ArrayList <Edicao> vetorCodEdicao = new ArrayList <Edicao>();
            vetorCodEdicao = (ArrayList<Edicao>) aux.buscaEdicoesPorEvento(codEven);
            
            nroEdicaoCombo.removeAllItems();
            for(int i=0; i<vetorCodEdicao.size();i++)
            {
                nroEdicaoCombo.addItem(vetorCodEdicao.get(i).getNroEdicao());
            }
        }
    }//GEN-LAST:event_codEventoComboActionPerformed

    private void nroEdicaoComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nroEdicaoComboActionPerformed
        numeroEdicao = Integer.parseInt(""+ nroEdicaoCombo.getSelectedItem());
               
        if(numeroEdicao == 0){
            System.out.println("Não tem nenhum evento selecionado");
        }
        else{
            
            ArrayList <Despesa> vetorDespesa = new ArrayList <Despesa>();
        //    vetorDespesa = (ArrayList<Despesa>) aux.buscarDespesaPorEventoEEdicao(codEven, (long)numeroEdicao);
            
            codDespesaCombo.removeAllItems();
            for(int i=0; i<vetorDespesa.size();i++)
            {
                codDespesaCombo.addItem(vetorDespesa.get(i).getNroEdicao());
            }
        }
    }//GEN-LAST:event_nroEdicaoComboActionPerformed

    private void codDespesaComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_codDespesaComboActionPerformed
        
    }//GEN-LAST:event_codDespesaComboActionPerformed

    private void botaoAlterarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoAlterarActionPerformed
        this.numeroEdicao = Integer.parseInt((String) nroEdicaoCombo.getSelectedItem());
        this.codDespesa = Long.parseLong((String) codDespesaCombo.getSelectedItem());
        this.codEvento = Long.parseLong((String) codEventoCombo.getSelectedItem());
        
        DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
        this.dataDespesa  = Calendar.getInstance();
        try {
            this.dataDespesa.setTime(df.parse(this.data1.getText()));
        } catch (ParseException ex) {
            Logger.getLogger(AtualizarDespesa.class.getName()).log(Level.SEVERE, null, ex);
            Component frame = null;
            JOptionPane.showMessageDialog(frame,ex.getMessage());
        }
                
        this.descricaoDespesa = descricao1.getText();
        this.valorDespesa = Float.valueOf(valor1.getText());
        this.tipoDespesa = tipoDesp1.getText();
        
        Despesa despesaAtualizada = null;
        despesa = new Despesa (despesa.getNroEdicao(),despesa.getCnpjPatrocinador(),despesa.getCodEventoPatrocinio(),despesa.getNroEdicaoPatrocinio(),dataDespesa,valorDespesa,descricaoDespesa,tipoDespesa,despesa.getCodEvento());
        try {
            aux.updateDespesa(despesaAtualizada);
        } catch (ExcecaoInstanciaNaoEncontrada ex) {
            Logger.getLogger(AtualizarDespesaApresentador.class.getName()).log(Level.SEVERE, null, ex);
            Component frame = null;
            JOptionPane.showMessageDialog(frame,ex.getMessage());
        } catch (ExcecaoSaldoInsuficiente ex) {
            Logger.getLogger(AtualizarDespesaApresentador.class.getName()).log(Level.SEVERE, null, ex);
            Component frame = null;
            JOptionPane.showMessageDialog(frame,ex.getMessage());
        }
    }//GEN-LAST:event_botaoAlterarActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoAlterar;
    private javax.swing.JButton botaoConsultar;
    private javax.swing.JButton botaoRetornar;
    private javax.swing.JComboBox codDespesaCombo;
    private javax.swing.JComboBox codEventoCombo;
    private javax.swing.JTextField data1;
    private javax.swing.JTextField dataText;
    private javax.swing.JTextField descricao;
    private javax.swing.JTextField descricao1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JComboBox nroEdicaoCombo;
    private javax.swing.JTextField tipoDesp;
    private javax.swing.JTextField tipoDesp1;
    private javax.swing.JTextField valor;
    private javax.swing.JTextField valor1;
    // End of variables declaration//GEN-END:variables
}
